﻿using UnityEngine;
using System.Collections;

public class CameraCtrl : MonoBehaviour
{
    private Vector3 mouseDownPos = Vector3.zero;
    private bool mouseDown = false;

    private Vector3 cameraPos = Vector3.zero;

    // Use this for initialization
    void Start()
    {

    }

    // Update is called once per frame
    void Update()
    {
        
        if (Input.GetMouseButtonDown(0))
        {
            mouseDown = true;
            mouseDownPos = Input.mousePosition;
            cameraPos = transform.position;

            //Debug.LogError("mouseDownPos:" + mouseDownPos);
        }

        if (Input.GetMouseButtonUp(0))
        {
            mouseDown = false;

            mouseDownPos = Input.mousePosition;
        }

        if (mouseDown)
        {
            float moveX = Input.mousePosition.x - mouseDownPos.x;

            moveX /= 50;

            //Debug.LogError("mouse Up:" + Input.mousePosition);

            transform.position = new Vector3(cameraPos.x + moveX, transform.position.y, transform.position.z);
        }


        
    }
}
